Learn R Programming

multimedia (version 0.2.0)

[,mediation_data,ANY,ANY,ANY-method: Subset a mediation dataset

Description

We can subset samples by indexing into a mediation dataset. It will subsample all fields -- pretreatments, treatments, mediators, and outcomes. Note that there is no way to subset columns in this way, since they would be different across each source.

Usage

# S4 method for mediation_data,ANY,ANY,ANY
[(x, i, j, ..., drop = TRUE)

Value

A version of the input mediation_data object whose @mediators, @outcomes, @treatments, and @pretreatments rows have all been subsetted according to i.

Arguments

x

An object of class mediation_data whose samples we want to subset.

i

An integer or integer/logical vector specifying the samples to subset to.

j

A placeholder to argree with R's [ function. Never used.

...

A placeholder to agree with R's [ function. Never used.

drop

A placeholder to agree with R's [ function. Never used.

Examples

Run this code
exper <- demo_joy() |>
    mediation_data("PHQ", "treatment", starts_with("ASV"))
exper[1]
exper[1:10]

Run the code above in your browser using DataLab